<template>
  <div v-loading="load">
    <div class="order-body">
      <el-tabs v-model="activeName">
        <el-tab-pane label="投保信息" name="1">
          <div style="display: flex; justify-content: space-between; align-items: center">
            <div class="orde-state-tag">保障中</div>
            <div style="display: flex">
              <div
                v-if="info.apply_url"
                style="
                  padding: 10px 16px;
                  border: 1px solid #5f7dfc;
                  border-radius: 5px;
                  color: #5f7dfc;
                  display: flex;
                  justify-content: center;
                  align-items: center;
                  margin-bottom: 10px;
                  cursor: pointer;
                "
              >
                <a :href="info.apply_url">下载投保单</a>
              </div>
              <div
                v-if="info.apply_url"
                style="
                  margin-left: 10px;
                  color: white;
                  padding: 10px 16px;
                  border-radius: 5px;
                  background-color: #5f7dfc;
                  display: flex;
                  justify-content: center;
                  align-items: center;
                  margin-bottom: 10px;
                "
              >
                <el-upload
                  class="upload-demo"
                  :action="url1"
                  :on-success="upSuccess1"
                  multiple
                  :data="{ id: id, apply_no: info.apply_no }"
                  :show-file-list="false"
                >
                  上传投保单
                </el-upload>
              </div>
              <div v-if="info.type == 2">
                <el-button
                  size="small"
                  class="com-btn"
                  @click="getApply()"
                  v-if="info.apply_no && !info.apply_url"
                  style="margin: 0 10px"
                  >获取投保单</el-button
                >
              </div>
            </div>
          </div>

          <el-descriptions class="margin-top" :column="1" size="small" border>
            <el-descriptions-item>
              <template slot="label"> 投保方案 </template>
              <span>{{ info.bx_name }}</span>
              <span v-if="info.fanan_memo">（{{ info.fanan_memo }}）</span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 保额 </template>
              <span>{{ info.fanan }}</span>
              <span v-if="info.level"> ({{ info.level }}) </span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 保单号 </template>
              <span>{{ info.bd_no }}</span>
              <span
                class="order-link-txt"
                style="margin-left: 10px"
                @click="downLoad(info.bd_url)"
                v-if="info.bd_url || info.type == 3"
                >下载电子保单</span
              >
               
              <span
                class="order-link-txt"
                style="margin-left: 10px"
                @click="getBdUrl(info.id)"
                v-if="info.bx_id == 15"
                >获取电子保单</span
              >
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 保险公司 </template>
              <span>{{ info.bx_memo }}</span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 保费 </template>
              <span>{{ info.total_price }}</span>
              <template v-if="info.type != 2">
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="info.fp_url"
                  @click="downLoad(info.fp_url)"
                  >下载电子发票</span
                >
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="info.fp_url_1 && info.bx_id == 15 && showTestFeatures"
                  @click="downLoad(info.fp_url_1)"
                  >下载电子发票1</span
                >

                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="!info.fp_url"
                  @click="getInvoice(info)"
                  >获取电子发票</span
                >
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="!info.fp_url_1 && info.bx_id == 15 && showTestFeatures"
                  @click="getInvoice(info)"
                  >获取电子发票1</span
                >
              </template>
              <template v-else>
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="info.fp_url"
                  @click="downLoad(info.fp_url)"
                  >下载电子发票1</span
                >
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="info.fp_two_url"
                  @click="downLoad(info.fp_two_url)"
                  >下载电子发票2</span
                >
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="!info.fp_url && info.state == 2 && info.fp_state == 0"
                  @click="getInvoice(info)"
                  >获取电子发票</span
                >
                <span
                  class="order-link-txt"
                  style="margin-left: 10px"
                  v-if="!info.fp_url && info.state == 2 && info.fp_state == 1"
                  >开票中</span
                >
              </template>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 期限 </template>
              <span>从{{ info.start_time }} 到 {{ info.end_time }}</span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 保险条款 </template>
              <!-- <div v-if="info.type == 1">
                <div class="order-link-txt" @click="todoc(5)">
                  中国太平洋财产保险股份有限公司雇主责任保险（2016版）条款
                </div>
                <div class="order-link-txt" @click="todoc(6)">
                  中国太平洋财产保险股份有限公司雇主责任保险（2016版）附加死亡及伤残补助金保险条款
                </div>
                <div class="order-link-txt" @click="todoc(6)">
                  中国太平洋财产保险股份有限公司雇主责任保险附加法律费用额外增加条款
                </div>
              </div> -->
              <div>
                <div
                  class="order-link-txt"
                  @click="todocGF(item.id)"
                  v-for="(item, index) in OrderDocList"
                  :key="index"
                >
                  {{ item.title }}
                </div>
              </div>
            </el-descriptions-item>
          </el-descriptions>
          <div v-if="info.bx_id != 10">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">投保企业</div>
            </div>
            <el-descriptions class="margin-top" :column="1" size="small" border>
              <el-descriptions-item>
                <template slot="label"> 企业名称 </template>
                <span>{{ info.insure.name }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 统一信用编码 </template>
                <span>{{ info.insure.client }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 联系人 </template>
                <span>{{ info.insure.contact }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 电话号码 </template>
                <span>{{ info.insure.contact_mobile }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 地址 </template>
                <span
                  >{{ info.insure.province }}{{ info.insure.city }}{{ info.insure.area
                  }}{{ info.insure.address }}</span
                >
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div v-if="info.bx_id == 10">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">投保人信息</div>
            </div>
            <el-descriptions class="margin-top" :column="1" size="small" border>
              <el-descriptions-item>
                <template slot="label"> 投保人 </template>
                <span>{{ info.insure.name }}</span>
              </el-descriptions-item>
              <el-descriptions-item v-if="info.insure.contact">
                <template slot="label"> 法人 </template>
                <span>{{ info.insure.contact }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 证件类型 </template>
                <span> {{ info.insure.type == 1 ? "统一信用代码" : "身份证" }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 证件号码 </template>
                <span>{{ info.insure.client }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 手机号码 </template>
                <span> {{ info.insure.contact_mobile }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 所属省市区 </template>
                <span>
                  {{
                    info.insure.province + "-" + info.insure.city + "-" + info.insure.area
                  }}</span
                >
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 详细地址 </template>
                <span>{{ info.insure.address }}</span>
              </el-descriptions-item>
              <!-- <el-descriptions-item>
                <template slot="label"> 邮箱 </template>
                <span> {{ info.insure.email }}</span>
              </el-descriptions-item> -->
            </el-descriptions>
          </div>

          <div v-if="info.bx_id == 10">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">被保人信息</div>
            </div>
            <el-descriptions class="margin-top" :column="1" size="small" border>
              <el-descriptions-item>
                <template slot="label"> 投保人 </template>
                <span>{{ info.insured.name }}</span>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label"> 证件类型 </template>
                <span> {{ info.insured.type == 1 ? "统一信用代码" : "身份证" }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 证件号码 </template>
                <span>{{ info.insured.card_no }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 手机号码 </template>
                <span> {{ info.insured.contact_mobile }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 所属省市区 </template>
                <span>
                  {{
                    info.insured.province +
                    "-" +
                    info.insured.city +
                    "-" +
                    info.insured.area
                  }}</span
                >
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 详细地址 </template>
                <span>{{ info.insured.address }}</span>
              </el-descriptions-item>
              <!-- <el-descriptions-item>
                <template slot="label"> 邮箱 </template>
                <span> {{ info.insured.email }}</span>
              </el-descriptions-item> -->
            </el-descriptions>
          </div>

          <div v-if="info.bx_id == 10">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">运输信息</div>
            </div>
            <el-descriptions class="margin-top" :column="1" size="small" border>
              <el-descriptions-item>
                <template slot="label"> 车牌号 </template>
                <span>{{ info.transport.voyage_no }}</span>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label"> 型号 </template>
                <span> {{ info.transport.vehicle_name }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 起运时间 </template>
                <span> {{ info.transport.shipment_date }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 起运地所属省市区 </template>
                <span>
                  {{
                    info.transport.departure_province +
                    "-" +
                    info.transport.departure_city +
                    "-" +
                    info.transport.departure_area
                  }}</span
                >
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 目的地所属省市区 </template>
                <span>
                  {{
                    info.transport.terminal_province +
                    "-" +
                    info.transport.terminal_city +
                    "-" +
                    info.transport.terminal_area
                  }}</span
                >
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 目的地详细地址 </template>
                <span>{{ info.transport.terminal_station }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 吨位数 </template>
                <span> {{ info.transport.toncount }}</span>
              </el-descriptions-item>
            </el-descriptions>
          </div>

          <div v-if="info.bx_id == 10">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">货物信息</div>
            </div>
            <el-descriptions
              class="margin-top"
              v-for="(item, index) in info.goods"
              :key="index"
              :column="1"
              size="small"
              border
            >
              <el-descriptions-item>
                <template slot="label"> 货位名称 </template>
                <span>{{ item.name }}</span>
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label"> 装载方式 </template>
                <span> {{ item.way }}</span>
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div v-for="(item, key) in info.open_arr" :key="'b' + key">
            <div class="form-window">
              <div class="form-window-line"></div>
              <div class="form-window-txt">被保人{{ key + 1 }}</div>
            </div>
            <el-descriptions class="margin-top" :column="1" size="small" border>
              <el-descriptions-item>
                <template slot="label"> 企业名称 </template>
                <span>{{ item.name }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 统一信用编码 </template>
                <span>{{ item.client }}</span>
              </el-descriptions-item>
              <!-- <el-descriptions-item>
                <template slot="label"> 负责人 </template>
                <span>{{ item.contact }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 电话号码 </template>
                <span>{{ item.contact_mobile }}</span>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 经营地址 </template>
                <span>{{ item.address }}</span>
              </el-descriptions-item> -->
            </el-descriptions>
          </div>
          <div class="form-window">
            <div class="form-window-line"></div>
            <div class="form-window-txt">保单生效日期</div>
          </div>
          <el-descriptions class="margin-top" :column="1" size="small" border>
            <el-descriptions-item>
              <template slot="label"> 录入日期 </template>
              <span>{{ info.create_time }}</span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 生效日期 </template>
              <span>{{ info.start_time }}</span>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label"> 失效日期 </template>
              <span>{{ info.end_time }}</span>
            </el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
        <el-tab-pane label="保障人员" v-if="this.info.bx_id != 15" name="2">
          <div v-if="info.bx_id != 9">
            <div class="inpbox">
              <input
                type="text"
                v-model="key_words"
                class="inpbox_inp"
                placeholder="请输入姓名或身份证号码"
                name=""
                id=""
              />
              <el-button class="com-btn" size="mini" @click="sosuoclick">搜索</el-button>
              <!-- <div class="sosuo" @click="sosuoclick">搜索</div> -->
            </div>
          </div>
          <el-table
            v-if="info.bx_id != 9"
            :key="1"
            size="mini"
            border
            :data="users"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              width="60px"
              v-if="user_state"
            ></el-table-column>
            <el-table-column label="姓名" prop="name" width="80px"></el-table-column>
            <el-table-column
              label="身份证号"
              prop="id_card"
              width="180px"
            ></el-table-column>
            <el-table-column label="保额" prop="fanan" width="80px"></el-table-column>
            <el-table-column label="有效时间" prop="id_card">
              <template slot-scope="scope">
                {{ scope.row.start_time }}-{{ scope.row.end_time }}
              </template>
            </el-table-column>
            <el-table-column label="生效原因" width="100px">
              <template slot-scope="scope">
                {{ scope.row.add_id == 0 ? "投保" : "批改" }}
              </template>
            </el-table-column>
          </el-table>
          <el-table
            v-if="info.bx_id == 9"
            size="mini"
            :key="2"
            border
            :data="stake"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="60px"></el-table-column>
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column label="编号" prop="no"></el-table-column>
            <!-- <el-table-column label="价值" prop="price"></el-table-column> -->
          </el-table>
          <div
            style="
              float: left;
              margin-top: 20px;
              color: red;
              margin-left: 10px;
              font-size: 16px;
            "
          >
            勾选需要替换出的人员
          </div>
          <div class="order-table-btns">
            <a
              href="/static/批改导入模板.xlsx"
              download
              target="_blank"
              style="color: #4e8efb; margin-right: 20px"
              >点击下载导入模板</a
            >
            <el-button size="small" @click="daoIn()">导入批改</el-button>
            <el-button size="small" @click="dao()">导出清单</el-button>
            <el-button size="small" v-if="user_state" class="com-btn" @click="tiHuan()"
              >批增人员</el-button
            >
            <el-button size="small" v-if="user_state" class="com-btn" @click="tiHuan()"
              >批改人员</el-button
            >
          </div>
        </el-tab-pane>
        <el-tab-pane label="批改记录" v-if="this.info.bx_id != 15" name="3">
          <el-table size="mini" border :data="p_list">
            <el-table-column
              label="生效日期"
              prop="start_time"
              width="140px"
            ></el-table-column>
            <el-table-column
              label="下单日期"
              prop="create_time"
              width="140px"
            ></el-table-column>
            <el-table-column
              label="保单号"
              prop="order_no"
              min-width="170px"
            ></el-table-column>
            <el-table-column
              label="批改单号"
              prop="pd_no"
              min-width="170px"
            ></el-table-column>
            <el-table-column label="状态" width="80px">
              <template slot-scope="item">
                <el-tag size="mini" type="info" v-if="item.row.state == 0">已取消</el-tag>
                <el-tag size="mini" type="danger" v-if="item.row.state == 1"
                  >待支付</el-tag
                >
                <el-tag size="mini" type="success" v-if="item.row.state == 2"
                  >已支付</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column label="操作" width="140px">
              <template slot-scope="item">
                <span class="order-link-txt" @click="see(item.row.id)">{{
                  item.row.state == 1 ? "去支付" : "详情"
                }}</span>
                <span
                  class="order-link-txt"
                  @click="downLoad(item.row.url)"
                  v-if="item.row.url"
                  >下载电子批单</span
                >
                <!--                <span class="order-link-txt" @click="getPd(item.row.id)" v-if="!item.row.url && !item.row.state == 2">获取电子批单</span>-->
                <span
                  class="order-link-txt"
                  @click="cancel(item.row.id)"
                  v-if="item.row.state == 1"
                  >取消</span
                >
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <div v-if="activeName == 1"></div>
      <div v-if="activeName == 2"></div>
      <div v-if="activeName == 3"></div>
    </div>
    <el-dialog
      :visible.sync="user_model"
      title="批改人员"
      width="800px"
      :append-to-body="true"
      :close-on-click-modal="false"
    >
      <div v-loading="loading">
        <div class="date-change-box">
          <div style="width: 90px; height: 30px; line-height: 30px">生效日期：</div>
          <div style="width: calc(100% - 90px); height: 30px; line-height: 30px">
            <el-date-picker
              @change="selectStartTime()"
              v-model="start_time"
              :picker-options="pickerOptions"
              type="date"
              size="small"
              placeholder="选择日期"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
            <span style="color: red; margin-left: 10px; font-size: 16px"
              >提醒:批改生效时间不能早于上次批改生效时间</span
            >
          </div>
        </div>
        <el-table size="mini" border :data="u_users">
          <el-table-column label="原姓名" prop="name"></el-table-column>
          <el-table-column label="原身份证号" prop="id_card"></el-table-column>
          <el-table-column label="姓名">
            <template slot-scope="item">
              <el-input
                type="text"
                v-model="item.row.new_name"
                placeholder="姓名"
                size="mini"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="身份证号">
            <template slot-scope="item">
              <el-input
                type="text"
                v-model="item.row.new_card"
                placeholder="身份证号"
                size="mini"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="item">
              <el-button icon="el-icon-delete" size="mini" @click="delUser(item.$index)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div class="order-table-btns" v-if="dec_num == 0">
          <el-button size="small" type="success" icon="el-icon-plus" @click="addUser()"
            >添加人员</el-button
          >
        </div>
        <div class="footer-text-box">
          <span class="text-grey">批增人员{{ inc_num }}人，批减人员{{ dec_num }}人</span>
          <span class="total-price-box" v-if="info.type == 1"
            >合计保费：{{ total_price }}元</span
          >
        </div>
        <div class="footer-btn-box">
          <el-button size="small" @click="cancleTh()">取消</el-button>
          <el-button size="small" class="com-btn" @click="tiHuanSubmit()"
            >下一步</el-button
          >
        </div>
      </div>
    </el-dialog>
    <el-dialog
      :visible.sync="dao_model"
      title="批改人员"
      width="800px"
      :append-to-body="true"
      :close-on-click-modal="false"
    >
      <div v-loading="loading">
        <div class="date-change-box">
          <div style="width: 90px; height: 30px; line-height: 30px">
            <span>生效日期：</span>
          </div>
          <div style="width: calc(100% - 290px); height: 30px; line-height: 30px">
            <el-date-picker
              @change="selectStartTime()"
              v-model="start_time"
              :picker-options="pickerOptions"
              type="date"
              size="small"
              placeholder="选择日期"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </div>
          <div
            style="
              width: 260px;
              height: 30px;
              line-height: 30px;
              display: flex;
              align-items: center;
            "
          >
            <div style="width: 100px">
              <el-upload
                class="upload-demo"
                :action="url"
                :on-success="upSuccess"
                multiple
                :data="{ id: id }"
                :show-file-list="false"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
            <div>
              <el-button size="small" class="com-btn" @click="daoSubmit()"
                >下一步</el-button
              >
              <el-button size="small" @click="cleanUp()">清除</el-button>
            </div>
          </div>
        </div>
        <el-table size="mini" border :data="dao_user">
          <el-table-column label="姓名" prop="name"></el-table-column>
          <el-table-column label="身份证号" prop="id_card"></el-table-column>
          <el-table-column label="批改类型">
            <template slot-scope="item">
              <el-tag type="success" size="mini" v-if="item.row.type == 1">增加</el-tag>
              <el-tag type="danger" size="mini" v-if="item.row.type == 2">删除</el-tag>
            </template>
          </el-table-column>
        </el-table>
        <div class="footer-text-box">
          <span class="text-grey">批增人员{{ inc_num }}人，批减人员{{ dec_num }}人</span>
          <span class="total-price-box" v-if="info.type == 1"
            >合计保费：{{ total_price }}元</span
          >
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      id: 0,
      url: "/seller/upload/uploadUpdateUser",
      url1: "/seller/order/uploadApply",
      info: {
        insure: {},
      },
      load: false,
      loading: false,
      key_words: "",
      activeName: "1",
      users: [],
      stake: [],
      u_users: [],
      user_state: 0,
      stake_state: 0,
      user_model: false,
      dao_model: false,
      p_list: [],
      open_arr: [],
      start_time: "",
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        },
      },
      dec_num: 0,
      inc_num: 0,
      total_price: 0,
      price: 0,
      dao_user: [],
      OrderDocList: [],
    };
  },
  mounted() {
    this.id = this.$route.params.id;
    if (this.$route.query.type) this.activeName = this.$route.query.type;
    this.getData();
    this.getPlist();
  },
  methods: {
    //获取投保单
    getApply() {
      this.loading = true;
      this.ajaxs("order/getApplyBd", {
        data: { id: this.id },
        success: (res) => {
          this.loading = false;
          if (res.code) {
            this.toast(res.code, "获取成功");
            this.getData();
          } else {
            this.toast(res.code, res.msg);
          }
        },
      });
    },
    getOrderDoc() {
      console.log(this.info);
      this.ajaxs("index/getInsureContent", {
        data: {
          id: this.info.bx_id,
        },
        success: (res) => {
          this.OrderDocList = res.msg.list;
        },
      });
    },
    upSuccess(e) {
      if (e.code) {
        this.dao_user = e.msg.user;
        this.dec_num = e.msg.dec_num;
        this.inc_num = e.msg.inc_num;
        this.totalPrice();
      } else {
        this.toast(e.code, e.msg);
      }
    },
    //上传投保单
    upSuccess1(e) {
      if (e.code) {
        this.toast(e.code, e.msg);
      }
    },
    daoIn() {
      this.dec_num = 0;
      this.inc_num = 0;
      this.price = 0;
      this.total_price = 0;
      this.dao_model = true;
    },
    cleanUp() {
      this.dao_user = [];
    },
    //选择开始时间
    selectStartTime() {
      this.ajaxs("order/getChangePrice", {
        data: {
          id: this.id,
          start_time: this.start_time,
        },
        success: (res) => {
          if (res.code) {
            this.price = res.msg;
            this.totalPrice();
          } else {
            this.toast(res.code, res.msg);
          }
        },
      });
    },
    getInvoice(item) {
      this.load = true;
      this.ajaxs("order/getInvoice", {
        data: {
          id: item.id,
        },
        success: (res) => {
          this.toast(res.code, res.msg);
          if (res.code) {
            this.getData();
          }
          this.load = false;
        },
      });
    },
    getPd(id) {
      this.ajaxs("order/getPd", {
        data: {
          id: id,
        },
        success: (res) => {
          this.toast(res.code, res.msg);
          if (res.code) {
            this.getPlist();
          }
        },
      });
    },
    getBdUrl(id) {
      this.load = true;
      this.ajaxs("order/getDownloadBd", {
        data: {
          order_id: id,
        },
        success: (res) => {
          // this.toast(res.code, res.msg);
          if (res.code) {
            // this.getData();
            this.toast(res.code, '获取成功');
            setTimeout(() => {
              window.open(res.msg)
            }, 1000);
          }
          this.load = false;
        },
      });
    },
    totalPrice() {
      this.total_price = ((this.inc_num - this.dec_num) * this.price).toFixed(2);
      console.log(this.price);
    },
    see(id) {
      this.$router.push({
        path: "/index/order/endorse/" + id,
      });
    },
    downLoad(url) {
      if (url) {
        window.open(url);
      }
    },
    todoc(type) {
      let routeData = this.$router.resolve({
        path: "/index/index/doc/" + type,
      });
      window.open(routeData.href, "_blank");
    },
    todocGF(id) {
      let routeData = this.$router.resolve({
        path: "/index/index/clause/" + id,
      });
      window.open(routeData.href, "_blank");
    },
    dao() {
      window.location.href = "/seller/Download/downloadOrderUser/id/" + this.id;
    },
    tiHuanSubmit() {
      if (!this.start_time) {
        this.toast(0, "请选择生效时间");
        return;
      }
      this.loading = true;
      this.ajaxs("order/changeOrderDo", {
        data: {
          order_id: this.id,
          user: this.u_users,
          start_time: this.start_time,
        },
        success: (res) => {
          this.loading = false;
          if (res.code) {
            this.$router.push({
              path: "/index/order/endorse/" + res.msg,
            });
          } else {
            this.toast(res.code, res.msg);
          }
        },
      });
    },
    daoSubmit() {
      if (!this.start_time) {
        this.toast(0, "请选择失效时间");
        return;
      }
      let url = "order/uploadChangeOrderDo";

      this.loading = true;

      this.ajaxs(url, {
        data: {
          order_id: this.id,
          user: this.dao_user,
          start_time: this.start_time,
        },
        success: (res) => {
          this.loading = false;
          if (res.code) {
            this.$router.push({
              path: "/index/order/endorse/" + res.msg,
            });
          } else {
            this.toast(res.code, res.msg);
          }
        },
      });
    },
    cancleTh() {
      this.user_model = false;
    },
    tiHuan() {
      //if(this.u_users.length == 0)return this.toast(0,'请选择要替换的人员');
      this.dec_num = this.u_users.length;
      this.inc_num = this.u_users.length;
      this.price = 0;
      this.total_price = 0;
      this.user_model = true;
      this.$forceUpdate();
    },
    handleSelectionChange(e) {
      this.u_users = e;
      this.$forceUpdate();
    },
    addUser() {
      if (this.dec_num > 0) return this.toast(0, "替换时不能添加人员");
      this.u_users.push({
        name: "----",
        id_card: "----",
        new_name: "",
        new_card: "",
      });
      this.inc_num = this.u_users.length;
      this.totalPrice();
    },
    delUser(index) {
      if (this.u_users[index]["id"]) {
        this.dec_num--;
      }
      this.u_users.splice(index, 1);
      this.inc_num = this.u_users.length;
      this.totalPrice();
    },
    getPlist() {
      this.ajaxs("order/orderUpdate", {
        data: {
          id: this.id,
        },
        success: (res) => {
          this.p_list = res.msg;
        },
      });
    },
    sosuoclick() {
      this.getUsers();
    },
    getUsers() {
      this.ajaxs("order/getOrderUser", {
        data: {
          id: this.id,
          key_words: this.key_words,
        },
        success: (res) => {
          this.users = res.msg.user;
          this.$forceUpdate();
          this.user_state = res.msg.state;
        },
      });
    },
    getOrderStake() {
      this.ajaxs("order/getOrderStake", {
        data: {
          id: this.id,
          key_words: this.key_words,
        },
        success: (res) => {
          this.stake = res.msg.stake;
          this.$forceUpdate();
          this.stake_state = res.msg.state;
        },
      });
    },
    getData() {
      this.load = true;
      this.ajaxs("order/orderDetail", {
        data: {
          id: this.id,
        },
        success: (res) => {
          this.info = res.msg;
          console.log(this.info);
          this.load = false;
          if (this.info.bx_id == 9) {
            this.getOrderStake();
          } else {
            this.getUsers();
          }
          this.getOrderDoc();
        },
      });
    },

    cancel(id) {
      this.ajaxs(this.info.type == 1 ? "order/cancelEndorse" : "order/cancelEndorse", {
        data: { id: id },
        success: (res) => {
          this.toast(res.code, res.msg);
          if (res.code) {
            this.getPlist();
          }
        },
      });
    },
  },
};
</script>

<style scoped>
@import "../../assets/css/order/list.css";
@import "../../assets/css/index/form.css";

.date-change-box {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.footer-btn-box {
  width: 100%;
  text-align: center;
  margin-top: 30px;
}

.footer-text-box {
  width: 100%;
  text-align: center;
  margin-top: 20px;
}

.text-grey {
  font-size: 13px;
  color: #999999;
}

.total-price-box {
  margin-left: 10px;
  font-size: 15px;
  color: #f95d4a;
}

.inpbox {
  display: flex;
  margin: 10px 0;
  /* justify-content: space-between; */
}

.inpbox_inp {
  margin-right: 20px;
  font-size: 16px;
  border-radius: 5px;
  padding: 2px 0px 2px 10px;
  border: 1px solid #ebeef5;
  color: #777777;
}

.sosuo {
  margin-top: 2px;
  font-size: 14px;
  color: #777777;
  cursor: pointer;
}

input[type="text"]:focus {
  outline: none;
}

input::-webkit-input-placeholder {
  /* 使用webkit内核的浏览器 */
  color: #999;

  font-size: 12px;
}
</style>
